跳到主要内容

github action rn

name: 自动构建
on:
workflow_dispatch:
pull_request:
types:
- closed

jobs:
build-android:
if: "github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'release: ')"
runs-on: ubuntu-latest
steps:
- env:
REQBODY: ${{github.event.pull_request.body}}
run: |
echo "${REQBODY}"
- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Setup jdk
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Pkgs
run: yarn install --frozen-lockfile
- name: Get Version
run: node -p -e '`VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
# - name: Setup Debug Session
# uses: csexton/debugger-action@master
- name: Build
run: |
cd ./android
chmod +x ./gradlew
./gradlew assembleRelease
- name: Generate Changelog
run: echo github.event_name

- name: Upload Artifact arm64-v8a
uses: actions/upload-artifact@v4
with:
name: app-arm64-v8a-release
path: android/app/build/outputs/apk/release/app-arm64-v8a-release.apk

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }} # 令牌
publish_dir: ./app/build/outputs/apk/release # 构建后的文件目录
external_repository: arickxuan/musicfreepub # 仓库B,格式为:user/repo
publish_branch: main # 仓库B的分支
manual:
runs-on: ubuntu-latest
if: "github.event_name == 'workflow_dispatch'"
steps:
- env:
REQBODY: ${{github.event.pull_request.body}}
run: |
echo "${REQBODY}"
- name: Checkout
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Setup jdk
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Pkgs
run: yarn install --frozen-lockfile
- name: Get Version
run: node -p -e '`VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
# - name: Setup Debug Session
# uses: csexton/debugger-action@master

- name: echo ssh info
uses: csexton/debugger-action@master
env:
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}

- name: Build
env:
RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
run: |
cd ./android
chmod +x ./gradlew
./gradlew assembleRelease
# ./gradlew assembleDebug
ls
- name: Generate Changelog
run: echo github.event_name

- name: Upload Artifact arm64-v8a
uses: actions/upload-artifact@v4
with:
name: app-arm64-v8a-release
path: android/app/build/outputs/apk/release/app-arm64-v8a-release.apk

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }} # 令牌
publish_dir: ./app/build/outputs/apk/release # 构建后的文件目录
external_repository: arickxuan/musicfreepub # 仓库B,格式为:user/repo
publish_branch: main # 仓库B的分支

- name: Upload APK to GitHub Releases
uses: softprops/action-gh-release@v1
with:
files: android/app/build/outputs/apk/release/*.apk
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}